﻿using SubWayElevatorPower.BUS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SubWayElevatorPower.Serial
{

    public class SerialServer
    {
        public static SerialDataProcess serial = new SerialDataProcess();
        public SerialServer()
        {
            JsonConfigHelper jsonConfigHelper = new JsonConfigHelper("appsettings.json");
            string name = jsonConfigHelper["PortName"];
            int BaudRate = Convert.ToInt32(jsonConfigHelper["BaudRate"]);
            int Parity = Convert.ToInt32(jsonConfigHelper["Parity"]);
            int DataBit = Convert.ToInt32(jsonConfigHelper["DataBits"]);
            int StopBits = Convert.ToInt32(jsonConfigHelper["StopBits"]);
            serial.Init();
            serial.Open485SerialPort_1(name, BaudRate, Parity, DataBit, StopBits);
            serial.CmdSend();
        }
    }
}
